|
1
|
|
|
import chai from 'chai'; |
|
2
|
|
|
import {toStudlyCaps, isLowerCase, isUpperCase, toCamelCase, toSnakeCase, toKebabCase} |
|
3
|
|
|
from '../src/string.cases'; |
|
4
|
|
|
|
|
5
|
|
|
describe('#toStudlyCaps(value)', () => { |
|
6
|
|
|
it('should match DeCamelize', () => { |
|
7
|
|
|
let fixtures = [ |
|
8
|
|
|
'deCamelize', |
|
9
|
|
|
'de-Camelize', |
|
10
|
|
|
'de camelize', |
|
11
|
|
|
'de camelize', |
|
12
|
|
|
'de Camelize', |
|
13
|
|
|
'de-camelize', |
|
14
|
|
|
'-de--camelize', |
|
15
|
|
|
'de_camelize', |
|
16
|
|
|
' de_camelize' |
|
17
|
|
|
]; |
|
18
|
|
|
|
|
19
|
|
|
fixtures.forEach(el => { |
|
20
|
|
|
chai.expect(toStudlyCaps(el)).to.equal('DeCamelize'); |
|
21
|
|
|
}); |
|
22
|
|
|
}); |
|
23
|
|
|
}); |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
describe('isLowerCase function', () => { |
|
27
|
|
|
it('should be true', () => { |
|
28
|
|
|
let fixtures = [ |
|
29
|
|
|
'', |
|
30
|
|
|
'foo', |
|
31
|
|
|
'foobarfoo' |
|
32
|
|
|
]; |
|
33
|
|
|
|
|
34
|
|
|
fixtures.forEach(el => { |
|
35
|
|
|
chai.expect(isLowerCase(el)).to.equal(true); |
|
36
|
|
|
}); |
|
37
|
|
|
}); |
|
38
|
|
|
it('should be false', () => { |
|
39
|
|
|
let fixtures = [ |
|
40
|
|
|
'fooA', |
|
41
|
|
|
'foobarfoAo' |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
fixtures.forEach(el => { |
|
45
|
|
|
chai.expect(isLowerCase(el)).to.equal(false); |
|
46
|
|
|
}); |
|
47
|
|
|
}); |
|
48
|
|
|
}); |
|
49
|
|
|
|
|
50
|
|
|
describe('isUpperCase function', () => { |
|
51
|
|
|
it('should be true', () => { |
|
52
|
|
|
let fixtures = [ |
|
53
|
|
|
'', |
|
54
|
|
|
'FOO', |
|
55
|
|
|
'FOOBARFOO' |
|
56
|
|
|
]; |
|
57
|
|
|
|
|
58
|
|
|
fixtures.forEach(el => { |
|
59
|
|
|
chai.expect(isUpperCase(el)).to.equal(true); |
|
60
|
|
|
}); |
|
61
|
|
|
}); |
|
62
|
|
|
it('should be false', () => { |
|
63
|
|
|
let fixtures = [ |
|
64
|
|
|
'FOOa', |
|
65
|
|
|
'FOOBARFOOa' |
|
66
|
|
|
]; |
|
67
|
|
|
|
|
68
|
|
|
fixtures.forEach(el => { |
|
69
|
|
|
chai.expect(isUpperCase(el)).to.equal(false); |
|
70
|
|
|
}); |
|
71
|
|
|
}); |
|
72
|
|
|
}); |
|
73
|
|
|
|
|
74
|
|
|
describe('#toCamelCase(value)', () => { |
|
75
|
|
|
it('should match camelCase', () => { |
|
76
|
|
|
let fixtures = [ |
|
77
|
|
|
'CamelCase', |
|
78
|
|
|
'camelCase', |
|
79
|
|
|
'Camel case', |
|
80
|
|
|
'Camel case', |
|
81
|
|
|
'camel Case', |
|
82
|
|
|
'camel-case', |
|
83
|
|
|
'-camel--case', |
|
84
|
|
|
'camel_case', |
|
85
|
|
|
' camel_case' |
|
86
|
|
|
]; |
|
87
|
|
|
|
|
88
|
|
|
fixtures.forEach(el => { |
|
89
|
|
|
chai.expect(toCamelCase(el)).to.equal('camelCase'); |
|
90
|
|
|
}); |
|
91
|
|
|
}); |
|
92
|
|
|
}); |
|
93
|
|
|
|
|
94
|
|
|
describe('#toSnakeCase(value)', () => { |
|
95
|
|
|
it('should match de_camelize', () => { |
|
96
|
|
|
let fixtures = [ |
|
97
|
|
|
'deCamelize', |
|
98
|
|
|
'de-Camelize', |
|
99
|
|
|
'de camelize', |
|
100
|
|
|
'de camelize', |
|
101
|
|
|
'de Camelize', |
|
102
|
|
|
'de-camelize', |
|
103
|
|
|
'-de--camelize', |
|
104
|
|
|
'de_camelize', |
|
105
|
|
|
' de_camelize' |
|
106
|
|
|
]; |
|
107
|
|
|
|
|
108
|
|
|
fixtures.forEach(el => { |
|
109
|
|
|
chai.expect(toSnakeCase(el)).to.equal('de_camelize'); |
|
110
|
|
|
}); |
|
111
|
|
|
}); |
|
112
|
|
|
}); |
|
113
|
|
|
|
|
114
|
|
|
describe('#toKebabCase(value)', () => { |
|
115
|
|
|
it('should match de_camelize', () => { |
|
116
|
|
|
let fixtures = [ |
|
117
|
|
|
'deCamelize', |
|
118
|
|
|
'de-Camelize', |
|
119
|
|
|
'de camelize', |
|
120
|
|
|
'de camelize', |
|
121
|
|
|
'de Camelize', |
|
122
|
|
|
'de-camelize', |
|
123
|
|
|
'-de--camelize', |
|
124
|
|
|
'de_camelize', |
|
125
|
|
|
' de_camelize' |
|
126
|
|
|
]; |
|
127
|
|
|
|
|
128
|
|
|
fixtures.forEach(el => { |
|
129
|
|
|
chai.expect(toKebabCase(el)).to.equal('de-camelize'); |
|
130
|
|
|
}); |
|
131
|
|
|
}); |
|
132
|
|
|
}); |
|
133
|
|
|
|